﻿using System;
using System.Collections.Generic;
using System.Text;
using SH;

namespace MTS
{
    internal class mtDMSServerCallback : mtOuterface<ImtDMSServerCallback>
    {
        public mtDMSServerCallback()
        {
            m_interfaceName = "mtDMSServerCallback";
            m_nClassID = ImtDMSServerCallback._classID;
        }

        protected override shErrorCode OnRequest(int nClassID, int nFuncID, string token, ref MTSSerializer sc)
        {
            shErrorCode ec = shErrorCode.sh_ec_NoInterface;

            switch (nFuncID)
            {

            case ImtDMSServerCallback.DMSServerScanRequest:
                    {
                        mtScanRequest req = new mtScanRequest();

                        sc.serialize(req);

                        mtScanResponse rsp;

                        ec = m_pCallback.OnScanRequest(token, req, out rsp);

                        if(ec == shErrorCode.sh_ec_Success)
                        {
                            sc = new MTSSerializer();

                            sc.serialize(rsp);
                        }
                  
                    }
                    break;
                case ImtDMSServerCallback.DMSServerSceneStepInfo:
                    {
                        mtSceneStepInfo info = new mtSceneStepInfo();

                        sc.serialize(info);

                        ec = m_pCallback.OnSceneStepInfo(token, info);

                    }
                    break;
                case ImtDMSServerCallback.DMSServerScanStepInfo:
                    {
                        mtScanStepInfo info = new mtScanStepInfo();

                        sc.serialize(info);

                        ec = m_pCallback.OnScanStepInfo(token, info);
                    }
                    break;
                case ImtDMSServerCallback.DMSServerCalibStepInfo:
                    {
                        mtCalibStepInfo info = new mtCalibStepInfo();

                        sc.serialize(info);

                        ec = m_pCallback.OnCalibStepInfo(token, info);
                    }
                    break;
                case ImtDMSServerCallback.DMSServerAutoDiagStepInfo:
                    {
                        mtAutoDiagStepInfo info = new mtAutoDiagStepInfo();

                        sc.serialize(info);

                        ec = m_pCallback.OnAutoDiagStepInfo(token, info);
                    }
                    break;
                case ImtDMSServerCallback.DMSServerAutoDiagReport:
                    {
                        mtAutoDiagReport info = new mtAutoDiagReport();

                        sc.serialize(info);

                        ec = m_pCallback.OnAutoDiagReport(token, info);
                    }
                    break;
                case ImtDMSServerCallback.DMSServerStationRunStatus:
                    {
                        mtGStationRunStatusInfo info = new mtGStationRunStatusInfo();

                        sc.serialize(info);

                        ec = m_pCallback.OnStationRunStatus(token, info);
                    }
                    break;
                default:
                    return ec;
            }

            return ec;
        }

    }
}
